﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;

namespace OAuth2AuthorizerDemo.Models
{
    public class GitHubProvider : OAuthProvider
    {
        private static readonly string GitAppKey = "12962baa5076527e99ff";
        private static readonly string GitAppSecret = "b986a55ef47ce32acc6fcfbf3838e6b15c6bd800";
        private static readonly string GitStateString = "Some git string";

        public GitHubProvider(string name) : base(name, GitAppKey, GitAppSecret, GitStateString)
        {

        }

        public override void GetAccessToken(string code)
        {
            var token = _authorizer.GetAccessToken(AppKey, AppSecret, RedirectUrl, code);
            Debug.Assert(token.ResponseTokens.Count == 1);
            Debug.Assert(token.ResponseTokens.Keys[0] == "scope");
            AccessCode = token.AccessToken;
        }
    }
}